package com.linzm.creationaltype.abstractfactory02.factory;


import com.linzm.creationaltype.abstractfactory02.Color.Color;
import com.linzm.creationaltype.abstractfactory02.Shape.Shape;
import com.linzm.creationaltype.abstractfactory02.enums.ShapeTypeEnum;
import com.linzm.creationaltype.abstractfactory02.enums.TypeInterface;

/**
 * @Author zimingl
 * @Date 2023/4/15 12:29
 * @Description: 图形工厂
 */
public class ShapeFactory extends AbstractFactory {
    @Override
    public Color getColor(String color) {
        return null;
    }

    /**
     * 使用 getShape 方法获取形状类型的对象
     *
     * @param shapeType shapeType
     * @return Shape
     */
    @Override
    public Shape getShape(String shapeType) throws Exception {
        TypeInterface shapeTypeEnum = ShapeTypeEnum.valueOf(shapeType);
        Class<?> clazz = shapeTypeEnum.getClazz();
        return (Shape) clazz.newInstance();
    }
}
